package com.jason.kotlin.singleton

/**
 *
 * @Author: Jason
 * @Date: 2017/7/23
 * @Time: 20:38
 */

class  LazyNotThreadSafe {

    companion object {
        val instance by lazy(LazyThreadSafetyMode.NONE) {
            LazyNotThreadSafe()
        }

        // 下面是另一种等价的写法,获取单例使用get方法
        private var instance2: LazyNotThreadSafe? = null

        fun get():LazyNotThreadSafe {
            if (instance2 == null) {
                instance2= LazyNotThreadSafe()
            }
            return instance2!!

        }



    }
}